Fox's Git Mirrors
Commit ff0f8e4398710b2174ffa9d57959450df67dca56
Parents : ee0104a
Author : Shane Smiskol <shane@smiskol.com>
Signature : Signature validation error
Date : 2026-05-28T20:58:58-07:00
Committer : GitHub <noreply@github.com>
Date : 2026-05-28T20:58:58-07:00
Nissan: filter angle to reduce jitter (#3415)
* try this
* filter angle
* filter angle
* just filter angle
* dt
* huh
Changes
Diff
diff --git a/opendbc/car/nissan/carcontroller.py b/opendbc/car/nissan/carcontroller.py
index 9724e359..42f693a2 100644
--- a/opendbc/car/nissan/carcontroller.py
+++ b/opendbc/car/nissan/carcontroller.py
@@ -1,9 +1,11 @@
+import numpy as np
from opendbc.can import CANPacker
-from opendbc.car import Bus, structs
+from opendbc.car import Bus, DT_CTRL, structs
from opendbc.car.lateral import apply_std_steer_angle_limits
from opendbc.car.interfaces import CarControllerBase
from opendbc.car.nissan import nissancan
from opendbc.car.nissan.values import CAR, CarControllerParams
+from opendbc.car.common.filter_simple import FirstOrderFilter
VisualAlert = structs.CarControl.HUDControl.VisualAlert
@@ -13,6 +15,8 @@ class CarController(CarControllerBase):
super().__init__(dbc_names, CP)
self.car_fingerprint = CP.carFingerprint
+ self.angle_filter = FirstOrderFilter(0.0, 0.1, DT_CTRL)
+
self.apply_angle_last = 0
self.packer = CANPacker(dbc_names[Bus.pt])
@@ -27,8 +31,15 @@ class CarController(CarControllerBase):
### STEER ###
steer_hud_alert = 1 if hud_control.visualAlert in (VisualAlert.steerRequired, VisualAlert.ldw) else 0
+ # At low speeds and at high steering angles, EPS is sensitive to jitter in angle request. Smooth to fix uncomfortable response.
+ if CC.latActive:
+ self.angle_filter.update_alpha(float(np.interp(CS.out.vEgo, [5, 10, 20], [0.2, 0.1, 0.0])))
+ self.angle_filter.update(actuators.steeringAngleDeg)
+ else:
+ self.angle_filter.x = actuators.steeringAngleDeg
+
# windup slower
- self.apply_angle_last = apply_std_steer_angle_limits(actuators.steeringAngleDeg, self.apply_angle_last, CS.out.vEgoRaw,
+ self.apply_angle_last = apply_std_steer_angle_limits(self.angle_filter.x, self.apply_angle_last, CS.out.vEgoRaw,
CS.out.steeringAngleDeg, CC.latActive, CarControllerParams.ANGLE_LIMITS)
lkas_max_torque = 0
Served by rngit 1.5.2 - Generated in 0.04s